<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>订单详情</title>
    <script src="js/vue.js"></script>
    <script src="js/axios.min.js"></script>
    <style>
        body {
            background-color: #fff8f6;
            font-family: 'Arial', sans-serif;
            margin: 0;
            padding: 0;
            color: #333;
        }

        header {
            background-color: #d62d20; /* KFC 红色 */
            color: white;
            padding: 20px 0;
            text-align: center;
            font-size: 28px;
            font-weight: bold;
        }

        .order-container {
            max-width: 600px;
            margin: 30px auto;
            padding: 25px;
            background-color: #ffffff;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
            border-radius: 12px;
        }

        .order-item {
            margin-bottom: 15px;
            font-size: 18px;
        }

        .order-item strong {
            color: #d62d20;
        }

        .dish-img {
            display: block;
            width: 100%;
            max-height: 250px;
            object-fit: cover;
            border-radius: 10px;
            margin-top: 10px;
            box-shadow: 0 2px 6px rgba(0,0,0,0.1);
        }

        footer {
            text-align: center;
            margin-top: 50px;
            color: #999;
        }
    </style>
</head>
<body>

<header>订单详情</header>

<div id="app" class="order-container">
    <div class="order-item">订单编号：<strong>{{ myorder.orderNumber }}</strong></div>
    <div class="order-item">商品名称：<strong>{{ myorder.dishName }}</strong></div>
    <div class="order-item">商品原价：<strong>{{ myorder.dishPrice }} 元</strong></div>
    <div class="order-item">优惠价格：<strong>{{ myorder.couponPrice }} 元</strong></div>
    <div class="order-item">订单价格：<strong>{{ myorder.orderPrice }} 元</strong></div>
    <div class="order-item">下订单时间：<strong>{{ myorder.orderCreateTime }}</strong></div>

    <div class="order-item">
        商品图片：
        <img :src="myorder.dishImg" alt="商品图片" class="dish-img">
    </div>
</div>

<footer>© 2025 肯德基订单系统</footer>

<script>
    new Vue({
        el: "#app",
        data: {
            myorder: {
                orderId: "",
                orderNumber: "",
                dishId: "",
                dishName: "",
                dishImg: "",
                dishPrice: "",
                orderPrice: "",
                couponName: "",
                couponPrice: "",
                mycouponId: "",
                orderCreateTime: ""
            }
        },
        mounted() {
            this.getByOrderId();
        },
        methods: {
            getByOrderId() {
                const urlParams = new URLSearchParams(window.location.search);
                const id = urlParams.get("id");
                axios.get("myorder/" + id).then(response => {
                    if (response.data.code === 200) {
                        this.myorder = response.data.data;
                    } else {
                        alert("订单加载失败：" + response.data.msg);
                    }
                }).catch(error => {
                    console.error(error);
                    alert("请求失败");
                });
            }
        }
    });
</script>

</body>
</html>
